import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import userData from '@/views/user/index'
import Layout from '@/layout'

Vue.use(Router)

const routes= [
    {path:'/login',component:()=>import('@/views/login/login')},
    {
      path: '/',
      component: Layout,
      name:'用户模块',
      redirect: '/user',
      children:[
        {
          path: '/user',
          name:'查看用户',
          component:()=>import('@/views/user/index') 
        },
        {
          path:'/userdetail',
          name:'详情',
          component:()=>import('@/views/user/details')
        }
    ]
    }
  ]


const router =new Router({
  routes
})

// router.beforeEach((to,from,next) => {
//   if(to.path==='/login') return next()
//   const token = window.sessionStorage.getItem('token')
//   if(!token) return next('/login')
//   next()
// })

export default router